package com.sise.rsc.repository;

import com.sise.rsc.entity.APackage;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface APackageRepository extends JpaRepository<APackage,Integer> {

    APackage findAPackageById(int id);
    APackage findAPackageByNo(String no);

    @Query("from APackage")
    List<APackage> findAllAPackage();
    @Modifying
    @Query("update APackage a set a.state=?1 where a.id=?2")
    void updateAPackageStateById(int state, int id);

    @Modifying
    @Query("update APackage a set a.state=?1 where a.no=?2")
    void updateAPackageStateByNo(int state,String no);

    @Query("from APackage a where a.user.id=?1")
    List<APackage> findAllAPackageByUserId(int uid);
}
